package cartagows;

import cartago.Artifact;
import cartago.CartagoException;
import cartago.OPERATION;
import cartago.OpFeedbackParam;

import java.util.Calendar;

public class TimeProviderArtifact extends Artifact{
    
    void init() throws Exception{
	}
	
	@OPERATION void getTime(OpFeedbackParam<String> timeValue) 
	{
		Calendar calendario = Calendar.getInstance();
		int hora =calendario.get(Calendar.HOUR_OF_DAY);
		int minutos = calendario.get(Calendar.MINUTE);
		int segundos = calendario.get(Calendar.SECOND);
        timeValue.set(hora + ":" + minutos + ":" + segundos);
    }
	
	@OPERATION void getDay(OpFeedbackParam<String> dayValue) 
	{
		Calendar calendario = Calendar.getInstance();
		int dia =calendario.get(Calendar.DAY_OF_MONTH);
		int mes = calendario.get(Calendar.MONTH)+1;
		int anio = calendario.get(Calendar.YEAR);
        dayValue.set(dia + "/" + mes + "/" + anio);
    }
}